package com.justreading.netty.inboundhandlerandoutboundhandler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author LYJ
 * @Description
 * @date 2021 年 11 月 09 日 下午7:47
 */
public class MyClientHandler extends SimpleChannelInboundHandler<Long> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.out.println("收到服务器的数据+" + msg);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("MyClientHandler  发送数据");
        for (int i = 0; i < 5; i++) {
            ctx.channel().writeAndFlush(12345678L);
        }
    }
}
